package main

/*
 // 先定义
 int goQSortCompare(void* a, void* b);
*/
import "C"
import (
	"fmt"
	"unsafe"
)

// 实现
//
//export goQSortCompare
func goQSortCompare(a, b unsafe.Pointer) C.int {
	pa, pb := (*C.int)(a), (*C.int)(b)
	return C.int(*pa - *pb)
}

func main() {
	values := []int32{42, 9, 101, 95, 27, 25}

	Sort(unsafe.Pointer(&values[0]),
		len(values), int(unsafe.Sizeof(values[0])),
		CompareFunc(C.goQSortCompare),
	)
	fmt.Println(values)
}
